<?php get_header() ?> 

<?php
global $query_string;
query_posts($query_string . "post_type=page&post_status=publish&posts_per_page=9999&orderby=menu_order&order=ASC");
if ( have_posts() ) : while ( have_posts() ) : the_post(); 
$home=get_post_meta($post->ID, 'home', true);
$gallery=get_post_meta($post->ID, 'gallery', true);
$portfolio=get_post_meta($post->ID, 'portfolio', true);
$news=get_post_meta($post->ID, 'news', true);
$contact=get_post_meta($post->ID, 'contact', true);
$pcat = get_option('of_portfolio_category');
$pcatid = get_cat_id($pcat);
$ncat = get_option('of_news_category');
$ncatid = get_cat_id($ncat);
?>

<?php if ( $home ) : ?>
<div id="home" class="borderline">
<?php the_content(); ?>
</div>


<?php elseif ( $portfolio ) : ?>
<!-- Begin Portfolio Section -->
<div id="<?php echo the_slug(); ?>">
  <div id="portfolio-wrapper">
  	<!-- Begin Portfolio Navigation -->
    <ul id="content" class="gallerynav">
      <li>Show:</li>
      <li class="selected-1 button2"><a href="#" data-value="all">All<span></span></a></li>
      <?php 
  $categories=  get_categories('child_of='.$pcatid.'&orderby=name'); 
  foreach ($categories as $cat) {
  	$input = '<li><a href="#" data-value="category-'.$cat->category_nicename.'">';
	$input .= $cat->cat_name;
	$input .= '</a></li>';
	echo $input;
  }
 ?>
    </ul>
    <!-- End Portfolio Navigation -->
    
    <!-- Begin Portfolio Elements -->
    <ul id="portfolio-gallery" class="grid">
    <?php $recent = new WP_Query(); ?>
<?php $recent->query('showposts=99999&orderby=date&order=desc'); ?>
<?php while($recent->have_posts()) : $recent->the_post(); ?>
 <?php $site_url=get_post_meta($post->ID, 'site_url', true);
$caption=get_post_meta($post->ID, 'caption', true);
$media=get_post_meta($post->ID, 'media', true); 
$image_url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>


<?php if ( in_category($pcatid) ) {?>

	<?php if ( $media ) : ?>
    <!-- Begin Media -->
       <li data-id="<?php echo "".get_the_id();?>" <?php post_class() ?>>
        <span class="boxgrid caption">
        	<!-- Begin Full Size Link and Description -->
			<a href="<?php echo get_post_meta($post->ID, "media", $single = true); ?>" rel="zoombox[<?php the_title(); ?>]" title="<?php if ( $caption ) : ?><?php echo get_post_meta($post->ID, "caption", $single = true); ?><?php else : ?><?php the_title(); ?><?php endif; ?>  <?php if ( $site_url ) : ?>| &lt;a href=&quot;<?php echo get_post_meta($post->ID, "site_url", $single = true); ?>&quot;&gt;Visit&lt;/a&gt;<?php else : ?><?php endif; ?>">
				<?php the_post_thumbnail(); ?><!-- Image Thumnail -->
			</a>
        	<!-- End Full Size Link and Description -->
        		
        	<!-- Begin Caption -->
        	<span class="cover boxcaption">
      			<strong><?php the_title(); ?></strong>
        	</span><!-- End Caption -->
        </span>
<?php
$otherson = get_post_meta($post->ID, 'others', false); 
$caption=get_post_meta($post->ID, 'caption', true);
if ($otherson) { ?>
	<span class="hiddenothers">
		<?php $others = get_post_meta($post->ID, 'others', false); ?>
		<?php foreach($others as $other) { ?>
			<a href="<?php echo ''.$other.'' ?>" rel="zoombox[<?php the_title(); ?>]" title="<?php if ( $caption ) : ?><?php echo get_post_meta($post->ID, "caption", $single = true); ?><?php else : ?><?php the_title(); ?><?php endif; ?>  <?php if ( $site_url ) : ?>| &lt;a href=&quot;<?php echo get_post_meta($post->ID, "site_url", $single = true); ?>&quot;&gt;Visit&lt;/a&gt;<?php else : ?><?php endif; ?>"></a>         
		<?php }?>
	</span>
<?php } ?>
      </li><!-- End Media -->

    <?php else : ?>
    
    
    <!-- Begin Image -->
       <li data-id="<?php echo "".get_the_id();?>" <?php post_class() ?>>
        <span class="boxgrid caption">
        	<!-- Begin Full Size Link and Description -->
			<a href="<?php echo $image_url;?>" rel="zoombox[<?php the_title(); ?>]" title="<?php if ( $caption ) : ?><?php echo get_post_meta($post->ID, "caption", $single = true); ?><?php else : ?><?php the_title(); ?><?php endif; ?>  <?php if ( $site_url ) : ?>| &lt;a href=&quot;<?php echo get_post_meta($post->ID, "site_url", $single = true); ?>&quot;&gt;Visit&lt;/a&gt;<?php else : ?><?php endif; ?>" >
				<?php the_post_thumbnail(); ?><!-- Image Thumnail -->
			</a>
        	<!-- End Full Size Link and Description -->
        		
        	<!-- Begin Caption -->
        	<span class="cover boxcaption">
        	 <strong><?php the_title(); ?></strong>
			</span><!-- End Caption -->
        </span>
      <?php
$otherson = get_post_meta($post->ID, 'others', false); 
$caption=get_post_meta($post->ID, 'caption', true);
if ($otherson) { ?>
	<span class="hiddenothers">
		<?php $others = get_post_meta($post->ID, 'others', false); ?>
		<?php foreach($others as $other) { ?>
			<a href="<?php echo ''.$other.'' ?>" rel="zoombox[<?php the_title(); ?>]" title="<?php if ( $caption ) : ?><?php echo get_post_meta($post->ID, "caption", $single = true); ?><?php else : ?><?php the_title(); ?><?php endif; ?>  <?php if ( $site_url ) : ?>| &lt;a href=&quot;<?php echo get_post_meta($post->ID, "site_url", $single = true); ?>&quot;&gt;Visit&lt;/a&gt;<?php else : ?><?php endif; ?>"></a>         
		<?php }?>
	</span>
<?php } ?>
      </li><!-- End Image  -->
    <?php endif; ?>
    
    
    <?php }?>
    <?php  endwhile; ?>
      
    </ul><!-- End Portfolio Elements -->
 </div> </div><!-- End Portfolio Section -->

<?php elseif ( $gallery ) : ?>
<div id="<?php echo the_slug(); ?>" class="borderline"> 
<ul class="gallery">
<?php
$args = array(
	'post_type' => 'attachment',
	'posts_per_page' => -1,
	'numberposts' => 9999,
	'post_status' => null,
	'order' => 'ASC',
	'orderby' => 'title',
	'post_parent' => $post->ID
	); 
$attachments = get_posts($args);
if ($attachments) {
	foreach ($attachments as $attachment) {
		$attachment_img =  wp_get_attachment_url( $attachment->ID);
        echo '<li><a title="'.$attachment->post_title.'" rel="zoombox['.$post->ID.']" href="'.$attachment_img.'">';
        echo  '<img src="'.get_bloginfo('template_url').'/functions/img_resize/timthumb.php?src='.$attachment_img.'&amp;w=225&amp;h=130&amp;zc=1" alt=""/>';
        echo '</a></li>';
	}
}
?>
</ul>
</div>

<?php elseif ( $news ) : ?>
<!-- Begin News Section -->
<div id="<?php echo the_slug(); ?>" class="borderline">
  <div id="news-wrapper">
  	
  	<!-- Begin News Navigation -->
    <div id="newslist">
    
      <!-- Begin Up Button -->
      <div class="scroll">
      	<a href="#" id="newslist-prev">1</a>
      </div><!-- End Up Button -->
      <ul>
      <?php
 $lastposts = get_posts('category='.$ncatid.'&numberposts=9999');
 foreach($lastposts as $post) :
    setup_postdata($post);
 ?>
 <li>
 	<div class="postdate">
        <div class="month"><?php the_time('M') ?></div>
        <div class="day"><?php the_time('d') ?></div>
        <div class="year"><?php the_time('Y') ?></div>
	</div>
    <a href="<?php the_permalink() ?>" class="heading" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo ShortenText(get_the_title()); ?></a><!-- Post Name -->
 </li><!-- End Entry Heading -->
 <?php endforeach; ?>
	</ul>
    <!-- End Navigation List -->
      
      
      <!-- Begin Down Button -->
      <div class="scroll">
      	<a href="#" id="newslist-next">2</a>
      </div><!-- End Down Button -->
      
    </div><!-- End News Navigation -->
    
     <!-- Begin News Text -->
    <div id="output">
    <?php
 $lastposts = get_posts('category='.$ncatid.'&numberposts=9999');
 foreach($lastposts as $post) :
    setup_postdata($post);
 ?>
 <div class="entry">
        <div class="scroll-pane show">
          <h2><?php the_title(); ?></h2> 
          	<p><?php the_content(); ?></p>
    	</div>
      </div><!-- End Entry -->
 <?php endforeach; ?>
	</div><!-- End News Text -->
<script type="text/javascript">
		$(document).ready(function() {
			$(".show").show();
			$(".hide").hide();
		});
	</script>
</div></div><!-- End News Section -->

<?php elseif ( $contact ) : ?>
 <!-- Begin Contact Section -->
 <div id="<?php echo the_slug(); ?>" class="borderline">
  <div id="contact-wrapper">
  
    <div class="contact-container">
    <div class="contact-top"></div>
      <div class="contact-mid"> 
        <!--begin:contact form block-->
        <div id="contactform"> 
          
          <!--begin:notice message block-->
          <div id="note"></div>
          <!--begin:notice message block-->
          
          <form id="ajax-contact-form" method="post" action="javascript:alert('success!');">
          <input class="required inpt" type="hidden" name="to" value="<?php echo get_option("of_email");?>" />
          <label>Name</label>
          <input class="required inpt" type="text" name="name" value="" />
          <br />
          <label>E-Mail</label>
          <input class="required inpt" type="text" name="email" value="" />
          <br />
          <label>Comments</label>
          <textarea class="textbox" name="message" rows="6" cols="30"></textarea>
          <br />
          <label>5-2+1=? </label>
          <input class="required inpt" type="text" name="answer" value="" />
          <br />
          <label id="load" style="display:none"></label>
          <input id="submit-button" class="button" type="submit" name="submit" value="Submit" />
          </form>
          <!--end:contact form block--> </div>
      
      <!-- Begin Information -->
      <div class="contact-right">
        <div class="contact-info">
          <ul>
           <?php if ( get_option('of_address') !='' ) {?>
            <li class="address"><?php echo get_option('of_address'); ?></li><!-- Adress -->
            <?php } else {?>
        <?php }?>
        
        <?php if ( get_option('of_phone') !='' ) {?>
            <li class="phone"><?php echo get_option('of_phone'); ?></li><!-- Phone Number -->
            <?php } else {?>
        <?php }?>
        
        <?php if ( get_option('of_display_email') !='' ) {?>
            <li class="email"><?php echo get_option('of_display_email'); ?></li><!-- Email Adress -->
            <?php } else {?>
        <?php }?>
        
        
        
        
        
          </ul>
        </div>
        <?php if ( get_option('of_twitter') !='' ) {?>
        <div class="message" id="twitter"></div><!-- Twitter -->
        <?php } else {?> 
        <?php }?>
        
        
        <div class="contact-info">
          <!-- Begin Social Icons -->
          <ul class="social">
        <?php if ( get_option('of_facebook') !='' ) {?>
        	<li><a href="<?php echo get_option('of_facebook'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-fb.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>

	<?php if ( get_option('of_lastfm') !='' ) {?>
        	<li><a href="<?php echo get_option('of_lastfm'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-fm.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>

	<?php if ( get_option('of_deviantart') !='' ) {?>
        	<li><a href="<?php echo get_option('of_deviantart'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-dev.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>
        
        <?php if ( get_option('of_tumblr') !='' ) {?>
        	<li><a href="<?php echo get_option('of_tumblr'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-tu.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>
        
        <?php if ( get_option('of_flickr') !='' ) {?>
        	<li><a href="<?php echo get_option('of_flickr'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-fl.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>
        
        <?php if ( get_option('of_stumbleupon') !='' ) {?>
        	<li><a href="<?php echo get_option('of_stumbleupon'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-su.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>
        
        <?php if ( get_option('of_delicious') !='' ) {?>
        	<li><a href="<?php echo get_option('of_delicious'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-del.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>
        
        <?php if ( get_option('of_friendfeed') !='' ) {?>
        	<li><a href="<?php echo get_option('of_friendfeed'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon-ff.png" alt="" /></a></li>
        <?php } else {?>
        <?php }?>
      		</ul>
          <!-- End Social Icons -->
        </div>
        
      </div><!-- End Information -->
      </div>
      <div class="contact-bottom"></div>
    </div>
    <div id="bottom">
      <div class="copyright"><?php echo get_option('of_footer_text'); ?></div>
      <div class="gototop"><a href="#home" class="scrolltop" title="Go To Top">Top</a></div>
      <div class="clear"></div>
    </div>
  </div></div><!-- End Contact Section -->

<?php else : ?>
 <!-- Begin Section -->
  <div id="<?php echo the_slug(); ?>" class="borderline">
   
    <!-- Begin Text -->
    <div class="section-container">
      <div class="section-top"></div>
      <div class="section-mid">      

				<?php the_content(); ?>

    </div>
    <div class="section-bottom"></div>
    </div><!-- End Text -->
    
  </div>
  <!-- End Section -->

<?php endif; ?>
<?php endwhile; endif; ?>

<?php wp_reset_query(); ?>
<?php get_footer() ?>